Imports MIMS.WRS.Entities
Imports MIMS.WRS.Business

Public Class TerritoryList
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents rptList As MyFramework.Web.UI.WebControls.Repeater
    Protected WithEvents crContent As MyFramework.Web.UI.WebControls.ContentRegion
    Protected WithEvents pageTitle As MyFramework.Web.UI.WebControls.ContentRegion
    Protected WithEvents Masterpage1 As MyFramework.Web.UI.WebControls.MasterPage

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Protected WithEvents ucPager As Pager

    Protected Function GetCountry(ByVal countryId As Object) As String
        If (countryId Is DBNull.Value) Then
            Return ""
        Else
            Try
                Return CountryService.GetCountry(Convert.ToInt32(countryId)).CountryName
            Catch ex As Exception
                Return ""
            End Try
        End If
    End Function

    Protected Function GetShowHDPricingOnIDSText(ByVal data As Object) As String
        If (data Is DBNull.Value OrElse Convert.ToBoolean(data) = True) Then
            Return "Y"
        Else
            Return "N"
        End If
    End Function

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not IsPostBack Then
            Dim totalRecords As Integer
            ucPager.PageSize = Config.PageSize
            rptList.DataSource = TerritoryService.GetTerritories(TerritoryColumns.Description, _
                MyFramework.OrderDirection.ASC, ucPager.PageIndex + 1, ucPager.PageSize, totalRecords)
            rptList.DataBind()
            ucPager.TotalRecords = totalRecords
        End If
    End Sub

    Protected Function GetIDNumberHTML(ByVal Container As Object) As String
        Dim idNumber As Object = DataBinder.Eval(Container, "DataItem.IDNumber")
        If (idNumber Is DBNull.Value OrElse Convert.ToInt32(idNumber).Equals(Nulls.NullInteger)) Then
            Return "&nbsp;"
        Else
            Return Convert.ToString(idNumber)
        End If
    End Function

End Class
